<?php
namespace Little\Controller;
use Think\Controller;
header("Content-type: text/html; charset=utf-8");
class MubanController extends Controller {
    //************************************存储form_id*****************************
    public function index(){
        $code         = I('code');
        $user         =  users("users","id",$code);
        $form_id      = I("formid");
        $sel          = sel("form_id","id,form_id","user_id = {$user['id']}");
        if($sel){
            $a            = explode(",",$sel['form_id']);
            array_push($a,$form_id);
            $b            = implode(",",$a);
            $up            = up_one("form_id","id = {$sel['id']}",array("form_id"=>$b));
        }else{
            $up            = ins("form_id",array("form_id"=>$form_id,"user_id"=>$user['id'],"create_at"=>time()));
        }
        if($up){ echo 1; }else{ echo 2; }
    }
}